<template>
  <div class="side-left_tabs">
    <Tree :data="value" :render="renderContent"> </Tree>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    value: {
      type: Array,
      default() {
        return {};
      }
    },
    type: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {};
  },
  computed: {},

  created() {
    this.childrenForEach(this.value);
  },
  mounted() {},
  methods: {
    childrenForEach(children) {
      //树形结构数据处理
      children.forEach(item => {
        if (item.expand) {
          item.expand = false;
        }
        if (item.children && item.children.length > 0) {
          this.childrenForEach(item.children);
        }
      });
    },
    renderContent(h, { data }) {
      //树形结构渲染
      return h(
        "div",
        {
          style: {
            width: "130px"
          },
          class: {
            itemLi: true
          }
        },
        [
          h(
            "span",
            {
              style: {
                display: 'inline-block',
                width: '100%',
              },
              on: {
                click: () => {
                  this.$emit("append", data);
                  // this.appcode(data)
                }
              }
            },
            [
              h("Icon", {
                props: {
                  type: "md-folder"
                },
                style: {
                  float: "left",
                  marginleft: "1px",
                  color: "#969696",
                  fontSize: "16px"
                },
              }),
              // h(
              //   "span",
              //   {
              //     style: {
              //       display: "inline-block",
              //       float: "left",
              //       marginRight: "10px"
              //     }
              //   },
              //   data.departName
              // ),
              h(
                "opendata",
                  {
                    style: {
                      float: "left",
                      marginRight: "10px"
                    },
                    props: {
                      type : 'departmentName',
                      openid : data.departName,
                    },
                  },
              ),
              h("span", {
                style: {
                  display: "inline-block",
                  float: "right",
                  marginleft: "30px"
                }
              })
            ]
          )
        ]
      );
    }
  }
};
</script>
<style lang="less" scoped></style>
